package com.jmlee.controller;

import com.jmlee.exception.Asserts;
import com.jmlee.pojo.CommonResult;
import com.jmlee.pojo.UserAddress;
import com.jmlee.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 用户个人信息服务接口
 * @Author jmLee
 * @Date 2021/3/10 14:37
 * @Version 1.0
 */
@RestController
public class UserController {

    @Autowired
    private UsersService usersService;

    /**
     * 用户收货地址信息
     *
     * @param userId
     * @return
     */
    @GetMapping("/userAddress/{userId}")
    public CommonResult userAddress(@PathVariable("userId") Long userId) {

        if (userId == null) {
            Asserts.fail("用户Id不能为空");
        }

        List<UserAddress> userAddresses = usersService.getUserAddresses(userId);

        return CommonResult.success(userAddresses);
    }

    /**
     * TODO 个人中心信息
     *
     * @return
     */
    @GetMapping("/userInfo/{userId}")
    public CommonResult userInfo(@PathVariable("userId") Long userId) {
        if (userId == null) {
            Asserts.fail("用户Id不能为空");
        }

        return null;
    }


}
